class Button{

  private int width;
  private int height;
  private int x;
  private int y;
  private color textColor;
  private color buttonColor;
  private String text;
  private char action;
  private boolean checked; 
  private byte type;
  
  Button(int x0, int y0, int w, int h, String txt, char act, color t, color b, int type1, boolean check){
    width = w;
    height = h;
    x = x0;
    y = y0;
    textColor = t;
    buttonColor = b;
    action = act;
    text = txt;
    type = byte(type1);
    checked = check;
    drawButton();
  }
  
  public int getWidth(){
    return width;
  }
  
  public boolean isChecked(){
    return checked;
  }
  
  public void setChecked(boolean stat){
    checked = stat;
  }
  
  public int getHeight(){
    return height;
  }
  
  public int getX(){
    return x;
  }
  
  public int getY(){
    return y;
  }  
  
  public char getAction(){
    return action;
  }
  
  public color getTextColor(){
    return textColor;
  }  
  
  public color getButtonColor(){
    return buttonColor;
  }
  
  public String getText(){
    return text;
  } 
 
  public void setTextColor(color c){
    textColor = c;
  }
  
  public void drawButton(){
    
    switch (type){
      case 2:
        textAlign(0);
        noStroke();
        fill(#000000);
        ellipse(x,y,width,height);
        
        if (checked){
          fill(#00ff00);
          ellipse(x, y, width - 6, height - 6);
        } 
        else{
          fill(#ffffff);
          ellipse(x, y, width - 6, height - 6);
        }
        
        fill(#000000);
        textSize(height * 0.55);
        text(this.text, x + width * 2 , y + floor(height / 5));
        stroke(#000000);
      break;  
      case 3:
        textAlign(0);
        noStroke();
        fill(#000000);
        rect(x - floor(width / 2), y - floor(height / 2), width, height);
        
        if (checked){
          fill(#00ff00);
          rect(x - floor(width / 2) + 3, y - floor(height / 2) + 3, width - 6, height - 6);
        } 
        else{
          fill(#ffffff);
          rect(x - floor(width / 2) + 3, y - floor(height / 2) + 3, width - 6, height - 6);
        }
        fill(#000000);
        textSize(height * 0.55);
        text(this.text, x + width * 2 , y + floor(height / 5));
        stroke(#000000);
      break;  
      case 1:
        fill(buttonColor);
        rect(x, y, width, height);
        fill(textColor);
        textSize(floor(width / 10));
        textAlign(CENTER, CENTER);
        text(this.text, x + floor(width / 2), y + floor(height / 2));
      break;
    }
    
    
  }
  
  public byte getType(){
    return type;
  }
  
  public void drawHighlightButton(){
    switch (type){
      case 1:
        fill(buttonColor);
        rect(x, y, width, height);
        fill(#0000ff);
        textSize(floor(width / 10));
        textAlign(CENTER, CENTER);
        text(this.text, x + floor(width / 2), y + floor(height / 2));
      break;
      case 2:
        noStroke();
        fill(#ff0000);
        ellipse(x,y,width,height);
        fill(#ffffff);
        ellipse(x, y, width - 6, height - 6);
        stroke(#000000);
      break;
      case 3:
        noStroke();
        fill(#ff0000);
        rect(x - floor(width / 2), y - floor(height / 2), width, height);
        fill(#ffffff);
        rect(x - floor(width / 2) + 3, y - floor(height / 2) + 3, width - 6, height - 6);
        stroke(#000000);
      break;  
    }
    
  }
 }

